﻿using System;
using System.Collections;

namespace QueueTest
{
    class Program
    {
        static void Main(string[] args)
        {
            Queue queue = new Queue();
            //三位人员报名参赛
            queue.Enqueue("Alice");
            queue.Enqueue("Bob");
            queue.Enqueue("Sinck");

            //将 Queue 实例中的元素复制到新数组再遍历数组
            object[] obj = queue.ToArray();
            foreach (var v in obj)
            {
                Console.WriteLine(v);
            }

            /*
             * GetEnumerator()方法
            IEnumerator enumerator = queue.GetEnumerator();
            while (enumerator.MoveNext())
            {
                Console.WriteLine(enumerator.Current);
            }
            */

            //当没人报名时
            while (queue.Count != 0)
            {
                Console.WriteLine(queue.Dequeue() + "已报名！");
            }
            Console.WriteLine("报名结束！");

            //判断Alice是否参加
            bool Name = queue.Contains("yy");
            if (Name)
            {
                Console.WriteLine(true);
            }
            else
            {
                Console.WriteLine(false);
            }
            
            
            

        }
    }
}
